<?php include _include(APP_PATH . 'view/admin/htm/header.inc.htm'); ?>
<div class="row">
    <div class="col-12">
        <div class="page-header" id="top">
            <h2 class="pageheader-title">服务范围</h2>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <form action="<?php echo url('shopadmin-service') ?>" method="POST" id="form">
                    <div class="form-group">
                        <label for="admin_shop" class="col-form-label">范围范围</label>
                        <textarea class="form-control" value="<?php echo $shop['service'] ?>" placeholder="" name="service" id="service" style="height: 300px;display:none;"><?php echo $shop['service'] ?></textarea>
    
                        <div id="editor_service" class="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="submit" class="orm-control-label"></label>
                        <button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<?php include _include(APP_PATH . 'view/admin/htm/footer.inc.htm'); ?>
<script src="https://unpkg.com/wangeditor@3.1.1/release/wangEditor.min.js" type="text/javascript"></script>
<script type="text/javascript">
	var E = window.wangEditor
	var editor_service = new E('#editor_service')
	var $message_service = $('#service')

	editor_service.customConfig.zIndex = 0
	//editor.customConfig.uploadImgShowBase64 = true
	//editor.customConfig.uploadImgServer = '<?php echo url('thread-upload') ?>'
	//editor.customConfig.uploadFileName = 'file'

	editor_service.customConfig.menus = [
		'head',  // 标题
		'bold',  // 粗体
		'fontSize',  // 字号
		'italic',  // 斜体
		'underline',  // 下划线
		'strikeThrough',  // 删除线
		'foreColor',  // 文字颜色
		'backColor',  // 背景颜色
		'link',  // 插入链接
		'list',  // 列表
		'justify',  // 对齐方式
		'quote',  // 引用
		'image',  // 插入图片
		'table',  // 表格
		'undo',  // 撤销
	]
	editor_service.create()
	editor_service.txt.html($message_service.val());
</script>
<script>
var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
    jform.reset();
    jsubmit.button('loading');
    var postdata = jform.serializeObject();
    postdata['service'] = editor_service.txt.html();
    $.xpost(jform.attr('action'), postdata, function(code, message) {
        if(code == 0) {
            $.alert(message);
            jsubmit.text(message).delay(1000).button('reset');
        } else if(xn.is_number(code)) {
            alert(message);
            jsubmit.button('reset');
        } else {
            jform.find('[name="'+code+'"]').alert(message).focus();
            jsubmit.button('reset');
        }
    });
    return false;
});
    
    
</script>